package com.controller;

import com.entity.RbacRole;
import com.entity.ResponseEntity;
import com.service.RbacRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("/rbacRole")
public class RbacRoleController {
    @Autowired
    RbacRoleService rbacRoleService;

    @GetMapping("/roles/{currentPage}/{pageSize}")
    public ResponseEntity findAll(@PathVariable int currentPage,@PathVariable int pageSize){
        return  rbacRoleService.findAll(currentPage,pageSize);
    }

    @GetMapping("/roles/{roleId}")
    public ResponseEntity findAll(@PathVariable int roleId){
        return  rbacRoleService.findRoles(roleId);
    }

    @PostMapping("/roles/{roleId}")
    public ResponseEntity changeMenus(@RequestBody int[] roles,@PathVariable int roleId){
        System.out.println("roles = " + Arrays.toString(roles));

        return rbacRoleService.changeMenus(roles,roleId);
    }
}
